<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base =  "${base}";
    </script>
</head>
<body>
<br>
<form class="layui-form " action="">
         <input type="hidden" id="repairId" name="repairId" value="${repair.repairId!}" >
          <div class="layui-form-item">
              <label class="layui-form-label">对应的结构id</label>
              <div class="layui-input-block">
                  <input type="text" id="structureId" name="structureId" value="${repair.structureId!}"  autocomplete="off" placeholder="请输入对应的结构id"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">修理原因及目的</label>
              <div class="layui-input-block">
                  <input type="text" id="subjects" name="subjects" value="${repair.subjects!}"  autocomplete="off" placeholder="请输入修理原因及目的"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">修理方法</label>
              <div class="layui-input-block">
                  <input type="text" id="method" name="method" value="${repair.method!}"  autocomplete="off" placeholder="请输入修理方法"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">发生频度</label>
              <div class="layui-input-block">
                  <input type="text" id="moreFrequent" name="moreFrequent" value="${repair.moreFrequent!}"  autocomplete="off" placeholder="请输入发生频度"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">工具设备</label>
              <div class="layui-input-block">
                  <input type="text" id="equipment" name="equipment" value="${repair.equipment!}"  autocomplete="off" placeholder="请输入工具设备"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">耗材</label>
              <div class="layui-input-block">
                  <input type="text" id="consumables" name="consumables" value="${repair.consumables!}"  autocomplete="off" placeholder="请输入耗材"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">修理难度</label>
              <div class="layui-input-block">
                  <input type="text" id="difficulty" name="difficulty" value="${repair.difficulty!}"  autocomplete="off" placeholder="请输入修理难度"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">修理费用估计</label>
              <div class="layui-input-block">
                  <input type="text" id="cost" name="cost" value="${repair.cost!}"  autocomplete="off" placeholder="请输入修理费用估计"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">修理级别</label>
              <div class="layui-input-block">
                  <input type="text" id="level" name="level" value="${repair.level!}"  autocomplete="off" placeholder="请输入修理级别"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">创建时间</label>
              <div class="layui-input-block">
                  <input type="text" id="createTime" name="createTime" value="${repair.createTime!}"  autocomplete="off" placeholder="请输入创建时间"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">更新时间</label>
              <div class="layui-input-block">
                  <input type="text" id="updateTime" name="updateTime" value="${repair.updateTime!}"  autocomplete="off" placeholder="请输入更新时间"
                         class="layui-input">
              </div>
          </div>

    <div align="center">
        <button type="button" class="layui-btn" id="submit">保存</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script>
    layui.use(['form', 'layer'], function() {
        var form = layui.form
                , layer = layui.layer;
        $("#submit").on("click",function () {
            if(check()===false){
                return;
            }

            var formDate = {
                         repairId:$("#repairId").val(),
                         structureId:$("#structureId").val(),
                         subjects:$("#subjects").val(),
                         method:$("#method").val(),
                         moreFrequent:$("#moreFrequent").val(),
                         equipment:$("#equipment").val(),
                         consumables:$("#consumables").val(),
                         difficulty:$("#difficulty").val(),
                         cost:$("#cost").val(),
                         level:$("#level").val(),
                         createTime:$("#createTime").val(),
                           updateTime:$("#updateTime").val()
            }
            $.ajax({
                type: "POST",
                url: base+"/api/repair/admin/editRepair",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href=base+"/api/repair/admin/main.html"
                    } else {

                    }
                }
            });
        })







        function check(){
                   if($("#structureId").val().length<1){
                       layer.msg("请输入对应的结构id");
                       return false;
                   }
                   if($("#subjects").val().length<1){
                       layer.msg("请输入修理原因及目的");
                       return false;
                   }
                   if($("#method").val().length<1){
                       layer.msg("请输入修理方法");
                       return false;
                   }
                   if($("#moreFrequent").val().length<1){
                       layer.msg("请输入发生频度");
                       return false;
                   }
                   if($("#equipment").val().length<1){
                       layer.msg("请输入工具设备");
                       return false;
                   }
                   if($("#consumables").val().length<1){
                       layer.msg("请输入耗材");
                       return false;
                   }
                   if($("#difficulty").val().length<1){
                       layer.msg("请输入修理难度");
                       return false;
                   }
                   if($("#cost").val().length<1){
                       layer.msg("请输入修理费用估计");
                       return false;
                   }
                   if($("#level").val().length<1){
                       layer.msg("请输入修理级别");
                       return false;
                   }
                   if($("#createTime").val().length<1){
                       layer.msg("请输入创建时间");
                       return false;
                   }
                   if($("#updateTime").val().length<1){
                       layer.msg("请输入更新时间");
                       return false;
                   }
        }
    });

</script>
</body>
</html>